We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the label to
be selected, unexpected things happen, since the action
applies to the current selection.
This is the equivalent of
cd9f5733b3e354301f2 for GtkLabel.
{
GtkLabel *self = GTK_LABEL (widget);
gboolean select_on_focus;
+ GtkWidget *prev_focus;
if (self->select_info == NULL)
return FALSE;
+ prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
+
if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget))
return FALSE;
&select_on_focus,
NULL);
- if (select_on_focus && !self->in_click)
+ if (select_on_focus && !self->in_click &&
+ !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
gtk_label_select_region (self, 0, -1);
}
else
{
- if (self->select_info->links && !self->in_click)
+ if (self->select_info->links && !self->in_click &&
+ !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
{
guint i;